package com.hspedu.seckill.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 消息发送者生产者
 */
@Component
public class MQSenderMessage {

    //装配RabbitTemplate
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sender(String message){
        //发送消息到 seckillExchange 队列，同时路由seckill.message 携带 message
        rabbitTemplate.convertAndSend("seckillExchange","seckill.message",message);
    }

}
